let rawcoco = require('./train.json')
let fs = require('fs')
let path = require('path')
let offset = 0;
(
    () => {
        for (let i = 0; i < rawcoco.annotations.length; i++) {
            //x,y,w,h
            rawcoco.annotations[i]["segmentation"] = [[
                rawcoco.annotations[i].bbox[0], //x
                rawcoco.annotations[i].bbox[1], //y
                rawcoco.annotations[i].bbox[0] + rawcoco.annotations[i].bbox[2], //x + w
                rawcoco.annotations[i].bbox[1], //y
                rawcoco.annotations[i].bbox[0] + rawcoco.annotations[i].bbox[2], //x + w
                rawcoco.annotations[i].bbox[1] + rawcoco.annotations[i].bbox[3], //y + h
                rawcoco.annotations[i].bbox[0], //x
                rawcoco.annotations[i].bbox[1] + rawcoco.annotations[i].bbox[3], //y + h

            ]]
            // console.log(temp)
        }
        fs.writeFileSync('instances_train2017_f.json', JSON.stringify(rawcoco))
    }
)()

